﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FlowCard
{
    public partial class frmLogin : Form
    {
        SQLTools sqt;

        public frmLogin()
        {
            InitializeComponent();
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            sqt = new SQLTools();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("请输入用户名！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUserName.Focus();
                return;
            }
            if (!sqt.RecordExist("select yh001 from yh_table where yh001='" + txtUserName.Text + "' and yh005='" + txtPassword.Text + "'"))
            {
                MessageBox.Show("用户名或密码有误，请检查后重新输入！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                txtUserName.Focus();
                return;
            }
            DataTable tmpdt=sqt .GetDataTable ("select yh002 用户名称,yh003 部门编号 from yh_table where yh001='" + txtUserName.Text + "' and yh005='" + txtPassword.Text + "'");
            if (tmpdt.Rows.Count > 0)
            {
                Form1 newForm1 = new Form1(tmpdt.Rows[0]["用户名称"].ToString(), tmpdt.Rows[0]["部门编号"].ToString());
                newForm1.Show();
                this.Close();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
